<admintpl file="header" />
</head>
<body class="J_scroll_fixed">
	<div class="wrap jj">
		<div class="common-form">
			<form method="post" class="form-horizontal J_ajaxForm" action="{:U('nav/edit_post')}">
				<fieldset>
					<div class="control-group">
						<label class="control-label">菜单分类:</label>
						<div class="controls">
							<select name="cid" id="navcid_select" class="normal_select">
								<foreach name="navcats" item="vo">
								<php>$navcid_selected=$navcid==$vo['navcid']?"selected":"";</php>
								<option value="{$vo.navcid}" {$navcid_selected}>{$vo.name}</option>
								</foreach>
							</select>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">上级:</label>
						<div class="controls">
							<select name="parentid" class="normal_select">
								<option value="0">/</option>
								{$nav_trees}
							</select>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">标签:</label>
						<div class="controls">
							<input type="text" class="input" name="label" value="{$label}"><span class="must_red">*</span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">地址:</label>
						<div class="controls">
							<input type="radio" name="nav" id="outlink">
							<input type="text" class="input" name="href" id="outlink_input" value="http://">
							<input type="radio" name="nav" id="selecturl">
							<select name="href" id="selecthref" class="normal_select">
								<option disabled>默认</option>
								<option value="home">首页</option>
								<foreach name="navs" item="vo">
								<option disabled>{$vo.name}</option>
									<foreach name="vo['items']" item="voo">
									<option value='{$voo.rule}'>{$voo.label}</option>
									</foreach>
								</foreach>
							</select>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">打开方式:</label>
						<div class="controls">
							<select name="target">
								<option value="">默认方式</option>
								<option value="_blank">新窗口打开</option>
							</select>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">图标:</label>
						<div class="controls">
							<input type="text" class="input" name="icon" value="{$icon}">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">显示:</label>
						<div class="controls">
							<select name="status" class="normal_select">
								<option value="1">显示</option>
								<php>$status_selected=empty($status)?"selected":"";</php>
								<option value="0" {$status_selected}>隐藏</option>
							</select>
						</div>
					</div>
				</fieldset>
				<div class="form-actions">
					<input type="hidden" class="input" name="id" value="{$id}">
					<button type="submit" class="btn btn-primary btn_submit J_ajax_submit_btn">更新</button>
					<a class="btn" href="__URL__">返回</a>
				</div>
			</form>
		</div>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
	<script>
		$(function() {
			$("#navcid_select").change(function() {
				if(location.search.indexOf("?")>=0){
					location.href = location.href + "&cid=" + $(this).val();
				}else{
					location.href = location.href + "?cid=" + $(this).val();
				}
				
				
			});

			$("#selecthref").click(function() {
				checkChange(2);
			});
			$("input[name='href']").click(function() {
				checkChange(1);
			});

			var opt = $("#selecthref option[value='" + '{$hrefold}' + "']");
			if (opt.length > 0) {
				opt.attr('selected', 'selected');
				checkChange(2);
			} else {
				checkChange(1);
				$('#outlink_input').val('{$hrefold}');
			}

			function checkChange(i) {
				if (i == 1) {
					//自动输入url
					$('#outlink_input').attr('name', 'href');
					$('#selecthref').removeAttr('name');
					$('#outlink').attr({
						'checked' : 'checked',
						'name' : 'nav'
					});
				} else {
					//选择链接url
					$('#selecthref').attr('name', 'href');
					$('#outlink_input').removeAttr('name');
					$('#selecturl').attr({
						'checked' : 'checked',
						'name' : 'nav'
					});
				}
			}
		});
	</script>
</body>
</html>